<?php
/**
 * @deprecated (暂时没用)
 * 商品图片处理
 *
 * Author: Zeon
 * Date: 2018/4/10
 * Created by Panxsoft.
 */
namespace App\Http\Controllers\Admin\Store\Product;

use App\Http\Controllers\ApiController;
use App\Http\Requests\Admin\Store\ProductImageDestroyRequest;
use App\Models\Admin\StoreAdmin;
use App\Models\Panx\ProductImage;
use Illuminate\Http\Request;

class ProductImageController extends ApiController
{
    /**
     * @param ProductImageDestroyRequest $request
     * @param $img_id
     * @return array|\Illuminate\Http\Response
     * @throws \Exception
     */
    public function destroy(ProductImageDestroyRequest $request, $img_id)
    {
        // 超管才能操作的
        $this->checkIsTrue(StoreAdmin::checkIsSuperMan(), trans('admin.is_super_man'));

        /** @var ProductImage $product_image */
        $img_ids = $request->product_image_ids ?? [$img_id];

        $deleted = ProductImage::destroy($img_ids);

        return $this->response(compact('deleted'));
    }

}

